﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dapper;
using System.Timers;
using System.Data.SqlClient;
using System.Data;
using Core;
using System.Threading;
using System.Net;

namespace DAL
{
    public class ReResourceRecordDAL : SyncBase<Model.ReResourceRecord>
    {
        static ReResourceRecordDAL()
        {
            StringBuilder strSql = new StringBuilder();
            ReResourceRecordDAL.addSQL = @"insert into ReResourceRecord(ResourceID,ResourceName,ReTypeCode,establishTeacher,UseTeacher,UseGrade,UseClass,Wplace,Wtime,IsPraise,LessonID,StepID,TimePoint,RecordTime)
                                                                values (@ResourceID,@ResourceName,@ReTypeCode,@establishTeacher,@UseTeacher,@UseGrade,@UseClass,@Wplace,@Wtime,@IsPraise,@LessonID,@StepID,@TimePoint,@RecordTime);";
            ReResourceRecordDAL.tbName = "ReResourceRecord";
            ReResourceRecordDAL.remoteUrl = "/Ayyfford/AddResourceRecord";
            ReResourceRecordDAL.setVal = (lt) =>
            {
                StringBuilder sb = new StringBuilder();
                string _ids = string.Empty;
                if (lt != null && lt.Count > 0)
                {
                    lt.ForEach(t =>
                    {
                        _ids += t.ID + ",";
                        sb.AppendFormat("({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13}),",
                            t.ResourceID.NullNumber(), t.ResourceName.NullString(), t.ReTypeCode.NullString(), t.establishTeacher.NullNumber(), t.UseTeacher.NullNumber(), t.UseGrade.NullString(), t.UseClass.NullNumber(), t.Wplace.NullNumber(), t.Wtime.NullDate(), t.IsPraise.NullNumber(), t.LessonID.NullNumber(), t.StepID.NullNumber(), t.TimePoint.NullNumber(), t.RecordTime.NullDate());
                    });
                }
                return new Tuple<string, string>(sb.ToString(), _ids);
            };
        }

        new public static void SaveEntity(Model.ReResourceRecord t)
        {
            SyncBase<Model.ReResourceRecord>.SaveEntity(t);
        }

        new public static void AsyncData()
        {
            SyncBase<Model.ReResourceRecord>.AsyncData();
        }
    }
}
